Skip to content

fix(plot): default to environment-managed Matplotlib display - #84

Open
huxiaoyi-ovo wants to merge 6 commits into
petercorke:mainfrom
huxiaoyi-ovo:fix/plot-block-contract-79
Open

huxiaoyi-ovo wants to merge 6 commits into
petercorke:mainfrom
huxiaoyi-ovo:fix/plot-block-contract-79

Conversation

@huxiaoyi-ovo

@huxiaoyi-ovo huxiaoyi-ovo commented Oct 20, 2026 •

Copy link
Copy Markdown

Summary

Fixes #79.

Updated Graph.plot() and Graph.highlight_path() to default to block=None, allowing Matplotlib display to be managed by the calling environment.

Previously, both methods defaulted to block=False and called plt.show(block=False) even when no display behaviour was specified. Explicit block=False and block=True retain their existing behaviour.

Documentation

  • Added versionchanged:: 1.1 notes to both methods.
  • Documented the behaviour change under Unreleased in the CHANGELOG.
  • Updated the README, documentation, and plotting examples to reflect the new default.

Scripts that previously relied on g.plot() opening a window can use plt.show() or block=False.

Tests

Added regression coverage for all three block modes, including default plotting followed by highlight_path(block=False) and plotting with caller-provided axes.

Fork CI passed: https://github.com/huxiaoyi-ovo/pgraph-python/actions/runs/41379496007

AI assistance: ChatGPT (GPT-6) assisted with code review, documentation, and regression tests.

huxiaoyi-ovo and others added 4 commits October 19, 2026 12:54
Align plot() and highlight_path() with the RVC block contract without changing explicit True/False handling.

Co-Authored-By: ChatGPT (OpenAI GPT-6) <noreply@openai.com>
Co-Authored-By: ChatGPT (OpenAI GPT-6) <noreply@openai.com>
Co-Authored-By: ChatGPT (OpenAI GPT-6) <noreply@openai.com>
Co-Authored-By: ChatGPT (OpenAI GPT-6) <noreply@openai.com>
@codacy-production

codacy-production Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 9 complexity · 0 duplication

Metric Results
Complexity 9
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Co-Authored-By: ChatGPT (OpenAI GPT-6) <noreply@openai.com>
@petercorke

Copy link
Copy Markdown
Owner

Thank you for your interest in pgraph-python, and for this contribution. This brings plot() and highlight_path() in line with the block= contract used across the RVC toolboxes (None leaves display to the environment, False shows without waiting, True waits). RTB's planners already default to None, and PRMPlanner.plot in particular calls Graph.plot without a block, so it should now behave properly. The three-state tests are just what is needed.

I'm happy to take this as a deliberate behaviour change. Before merging, could you:

  1. Mark the change in the docstrings. Add a .. versionchanged:: 1.1 note to both plot() and highlight_path() saying the default changed from False to None, so plt.show() is no longer called unless block is given, and how to get the old behaviour (block=False).
  2. Add a CHANGELOG entry in a new Unreleased section at the top of the file (this will become 1.1.0), under a "Behaviour change" heading, naming who is affected: anyone who called g.plot() in a script or an IPython terminal (without %matplotlib or plt.ion()) and relied on a window appearing. They now need plt.show(), or block=False.
  3. Update the other docs and examples that show plotting: examples/roads.ipynb (it can drop its explicit block=None) and any runblock or other examples in docs/ that call plot() or highlight_path(). Please check that they still produce a figure.
  4. Link the issue and expand the description: please add Fixes #79 and say what the old behaviour was and what you changed.
  5. Test the other mix: plot() with the default followed by highlight_path(block=False), and plot(block=None, ax=...) with a caller-supplied axes.

Thanks again, and let me know if you'd rather I made any of these changes myself.

@huxiaoyi-ovo

Copy link
Copy Markdown
Author

Hi Peter,

I've pushed the requested updates. Both plotting methods now have versionchanged:: 1.1 notes, and the CHANGELOG explains the behaviour change for scripts and IPython users. I've also updated the documentation and examples, with regression tests covering both mixed-use cases you mentioned.

The branch is up to date with main, and fork CI passed: https://github.com/huxiaoyi-ovo/pgraph-python/actions/runs/41379496007

Could you approve the upstream CI run when convenient? Thanks for the detailed review!

@huxiaoyi-ovo huxiaoyi-ovo changed the title fix(plot): default to environment-managed Matplotlib display fix(plot): default to environment-managed Matplotlib display Fixes #79 Nov 3, 2026
@huxiaoyi-ovo huxiaoyi-ovo changed the title fix(plot): default to environment-managed Matplotlib display Fixes #79 fix(plot): default to environment-managed Matplotlib display Fixes Nov 3, 2026
@huxiaoyi-ovo huxiaoyi-ovo changed the title fix(plot): default to environment-managed Matplotlib display Fixes fix(plot): default to environment-managed Matplotlib display Nov 10, 2026
@codecov

codecov Bot commented Nov 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.12%. Comparing base (0c33e9b) to head (998bdfd).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #84   +/-   ##
=======================================
  Coverage   98.12%   98.12%           
=======================================
  Files           4        4           
  Lines        1649     1649           
=======================================
  Hits         1618     1618           
  Misses         31       31           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

block=: follow the ecosystem contract (None / False / True), and review the default

2 participants